package com.ecommerce.dal.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ecommerce.dal.dao.impl.CustomerDAO;
import com.ecommerce.dal.dao.impl.CustomerItemDAO;
import com.ecommerce.dal.entity.Customer;
import com.ecommerce.dal.entity.CustomerItem;
import com.ecommerce.dal.service.ICustomerManagerService;



@Service("customerManagerService")
public class CustomerManagerService implements ICustomerManagerService {

	@Autowired
	CustomerDAO customerDAO;
	@Autowired
	CustomerItemDAO customerItemDAO;
	@Override
	public Customer retrieveCustomer(long customerId) {
		return customerDAO.findByCustomerId(customerId);
	}

	@Override
	public Customer retrieveCustomer(String customerUserName) {
		return customerDAO.findByCustomerName(customerUserName);
	}

	@Override
	public void saveCustomer(Customer customer) {
		customerDAO.save(customer);
		
	}

	@Override
	public List<CustomerItem> retrieveCutomerItems(long customerId) {
		return customerItemDAO.findByCustomerId(customerId);
	}

	@Override
	public void saveCustomerItem(CustomerItem customerItem) {
		customerItemDAO.save(customerItem);
		
	}

//	@Override
//	public void setAllCustomerItems(List<CustomerItem> customerItems) {
//		// TODO Auto-generated method stub
//		
//	}

	@Override
	public CustomerItem retrieveItemByVerification(long customerId,
			long verification) {
		return customerItemDAO.findByVerificationAndId(customerId, verification);
	}

	@Override
	public CustomerItem retrieveItemByVerification(String customerUserName,
			long verification) {
		return customerItemDAO.findByVerificationAndUserName(customerUserName, verification);
	}

	@Override
	public CustomerItem retrieveItemByVerification(long verification) {
		return customerItemDAO.findByVerification(verification);
	}

	@Override
	public Customer retrieveCustomerByVerification(long verification) {
		return customerItemDAO.findCustomerByVerification(verification);
	}
	@Override
	public void updateCustomer(Customer customer) {
		customerDAO.update(customer);
		
	}
	@Override
	public void deleteCustomer(Customer customer) {
		customerDAO.delete( customer);
		
	}

	@Override
	public Customer findByCustomerId(long customerId) {
		return customerDAO.findByCustomerId(customerId);
	}

	@Override
	public boolean checkIfClient(long customerId) {
		return customerDAO.checkIfClient(customerId);
	}

	@Override
	public boolean checkIfExists(long customerId) {
		return customerDAO.checkCustomerId(customerId);
	}

	@Override
	public List<Customer> retrieveVerifiedCustomers() {
		return customerDAO.findVerifiedCustomers();
	}

	@Override
	public List<Customer> retrieveNonVerifiedCustomers() {
		return customerDAO.findNonVerifiedCustomers();
	}

	@Override
	public boolean isVerifiedCustomer(long customerId) {
		return customerDAO.isVerified(customerId);
	}


}
